/**
 * Created by jimmy on 17/3/24.
 */
import { Base } from '../../utils/base.js'

class Agent extends Base {
  constructor() {
    super();
  }
  //页面加载查询推荐信息
  selRecommend(callback) {
    this.request({
      url: 'selRecommend',
      type: 'post',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      sCallback: function (data) {
        callback && callback(data)
      }
    })

  }
  //查询提车的数据
  selToCraData(callback) {
    this.request({
      url: 'selToCraData',
      type: 'post',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      sCallback: function (data) {
        callback && callback(data)
      }
    })
  }
  /**
    * js时间戳转时间
    * @param unknown timeStamp
    * @return '2013-12-1 12：80：08'
    */
  formatDateTime(timeStamp) {
    var date = new Date();
    date.setTime(timeStamp * 1000);
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    var h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    var minute = date.getMinutes();
    var second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    return y + '-' + m + '-' + d;
  }
  //提交生成二维码请求
  setQrCodeModel(callback) {
    this.request({
      url: 'setQrCode',
      type: 'post',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      sCallback: function (data) {
        callback && callback(data)
      }
    })

  }
  //页面加载查询qrcode
  selQrcodeMode(callback) {
    this.request({
      url: 'selQrcodData',
      type: 'post',
      header: {
        'content-type': 'application/json',
        'token': wx.getStorageSync('token')
      },
      sCallback: function (data) {
        callback && callback(data)
      }
    })

  }
}



export { Agent }